/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tomasio.projects.welcome.model;

import com.tomasio.projects.welcome.dto.ProibicaoDeAcessoDTO;

/**
 *
 * @author administrador
 */
public class ProibicaoDeAcesso {

    private Long id;
    private Periodo periodo;
    private String motivo;
    private Long transeunteId;

    public ProibicaoDeAcesso() {
    }


    public ProibicaoDeAcesso(ProibicaoDeAcessoDTO dto) {
        if (dto != null){
            this.id = dto.getId();
            this.transeunteId = dto.getTranseunteId();
            if(dto.getPeriodo() != null){
                this.periodo = new Periodo(dto.getPeriodo());
            }
            this.motivo = dto.getMotivo();
            if (dto.getTranseunte() != null){
                this.transeunteId = dto.getTranseunte().getId();
            }
        }
    }



    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getTranseunteId() {
        return transeunteId;
    }

    public void setTranseunteId(Long transeunteId) {
        this.transeunteId = transeunteId;
    }


    public Periodo getPeriodo() {
        return periodo;
    }

    public String getMotivo() {
        return motivo;
    }

    public void setMotivo(String motivo) {
        this.motivo = motivo;
    }

    public void setPeriodo(Periodo periodo) {
        this.periodo = periodo;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ProibicaoDeAcesso other = (ProibicaoDeAcesso) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 43 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
    
    public ProibicaoDeAcessoDTO createDTO(){
        ProibicaoDeAcessoDTO dto = new ProibicaoDeAcessoDTO();
        dto.setId(id);
        dto.setTranseunteId(transeunteId);
        dto.setMotivo(motivo);
        if(periodo != null){
            dto.setPeriodo(periodo.createDTO());
        }
        
        return dto;
    }

}
